<?php
/**
 * @file wxuser.php $
 * @author LiangJian (liangjian@haibao.com) $
 * @date 2015年6月23日 上午11:20:38 $
 * @brief 微信用户 $
 */
namespace haibao\cms\business;

class WxUser extends \haibao\cms\business\Base{
    
    private static $_instance;
    
	private static function instance(){
		if(!self::$_instance){
			self::$_instance = new \haibao\cms\data\WxUser();
		}
		return self::$_instance;
	}
    
    /**
     * 根据微信用户ID查询用户信息
     */
    public static function getUserByWxId($wxId){
        return self::instance()->getUserByWxId($wxId);
    }
    
    /**
     * 保存微信用户信息
     * @param \haibao\cms\model\data\WxUser $model
     */
    public static function saveWxUser($model){
        if(!$model->WxId){
            throw new BusinessException('微信ID不能为空');
        }
        $model->IP = ip2long($model->IP);
        $model->AddTime = new \DateTime();
        return self::instance()->saveUser($model);
    }
    
}